/*
 * Copyright (c) 2009, Jan Pastor. All Rights Reserved.
 */

package sk.jp.jitag;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import sk.jp.commons.utils.LogMsg;
import sk.jp.jitag.dao.JitagDao;
import sk.jp.jitag.vo.SearchInput;

/**
 * Search logic.
 */
@Component
public class SearchService {

    private static final Logger log = LoggerFactory.getLogger(SearchService.class);

    @SuppressWarnings({"SpringJavaAutowiringInspection"})
    @Autowired
    private JitagDao dao;

    //----------------------------------------------------------------------

    public void search(SearchInput input){
        if(log.isDebugEnabled()){
            log.debug(LogMsg.inp("input", input));
        }

        //TODO Dokoncit!!!


        //TODO test
        dao.beginTransaction();
        try {
//            dao.testSearch();
            dao.commitTransaction();
        } catch (Exception e) {
            log.error("error", e);
            dao.rollbackTransaction(e);
        }
    }

    @Deprecated
    public void testSetup(){
//        dao.testSetup();
    }

}
